class CreateElections < ActiveRecord::Migration
  def self.up
    create_table :elections do |t|
      t.date :start_date, :null => false
      t.date :end_date, :null => false
      t.string :title, :unique => true, :null => false, :limit => 128
      t.boolean :public, :default => true
      t.boolean :active, :default => false
      t.boolean :expired, :default => false      
      t.integer :votes_count, :default => 0      
      t.integer :ballots_count, :default => 0
      t.integer :user_id, :null => false
      t.auto_dates
    end
    add_index :elections, :active    
    add_index :elections, :expired    
  end

  def self.down
    drop_table :elections
  end
end
